<%@page import="lib_model.Product.Products"%>
<%@page import="lib_model.Product.Tax_product"%>
<%@page import="lib_model.Product.Image_products"%>
<%@page import="java.util.ArrayList"%>
<%@page import="lib_model.Categories.Categories"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<jsp:include page="../templates/Admin.jsp"></jsp:include>
Create Product
<jsp:include page="../templates/Title.jsp"></jsp:include>
<link href="../uploadify/uploadify.css" type="text/css" rel="stylesheet" />
<script src="../uploadify/swfobject.js"></script>
<script src="../uploadify/jquery.uploadify.v2.1.0.min.js"></script>
<script type="text/javascript">
            $(document).ready(function() {
                $('#uploadify').uploadify({
                    'uploader': '../uploadify/uploadify.swf',
                    'script': '../UploadFile?id=' + <%=request.getParameter("id")%>,
                    'folder': '../uploads',
                    'cancelImg': '../uploadify/cancel.png',
                    'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg',
                    'sizeLimit': 10240000,
                    'queueSizeLimit': 7,
                   	'auto'      : true,
                    'multi' :true,
                    'onComplete': function (event, queueID, fileObj, response, data) {
                        $("#attTable").append("<img style='border:1px solid red; margin:3px;' height='80px' src='../uploads/"+ fileObj.name +"' border=0 />");
                    }
                });
            });
        </script>
<jsp:include page="../templates/StyleAd.jsp"></jsp:include>
<div class="body-center w960">
<h2 class="title-show">Create New Product</h2>
<fieldset><legend>Create Product</legend>

<form
	action="../product/ProductCreate?id=<%=request.getParameter("id")%>"
	method="post">
<%
	Products pro = (Products) ((new Products((Integer.parseInt(request
			.getParameter("id")))).GetInformation().ObjResult));
%>


<table>
	<tr>
		<td>Categories</td>
		<td><select name="txtCater">
			<%
				ArrayList<Categories> cates = (ArrayList<Categories>) (new Categories())
						.Select().ObjResult;
			%>
			<%
				for (Categories cat : cates) {
					String r = "";
					if (pro.categories_id_ref == cat.id) {
						r = "selected='selected'";
					}
			%>
			<option <%=r%> value="<%=cat.id%>"><%=cat.name%></option>
			<%
				}
			%>

		</select></td>
	</tr>
	<tr>
		<td>Name Product</td>
		<td><input type="text" name="txtName" value="<%=pro.name%>" /></td>
	</tr>
	<tr>
		<td>Price</td>
		<td><input type="text" name="txtPrice" value="<%=pro.price%>" /></td>
	</tr>
	<tr>
		<td>Tax</td>
		<td>
		<%
			Tax_product tax = new Tax_product();
			ArrayList<Tax_product> ltax = ((ArrayList<Tax_product>) tax
					.Select().ObjResult);
		%> <Select name="txtTax">
			<%
				for (Tax_product tx : ltax) {
					String s = "";
					if (pro.tax_product_id_ref == tx.id) {
						s = "selected='selected'";
					}
			%>
			<option <%=s%> value="<%=tx.id%>"><%=tx.value%></option>
			<%
				}
			%>
		</Select></td>
	</tr>
	<tr>
		<%
			String c = "";
			String c2 = "checked='checked'";
			if (pro.type == 0) {
				c2 = "";
				c = "checked='checked'";
			}
		%>
		<td>Status</td>

		<td>Active <input type="radio" name="sta" value="1" <%=c2%> />
		Deactive <input type="radio" name="sta" value="0" <%=c%> /></td>
	</tr>
	<tr>
		<td>Description</td>
		<td><textarea cols="50" style="height: 74px;" name="txtDes""><%=pro.description%></textarea></td>
	</tr>
	<tr>
		<td>Upload Image</td>
		<td><input id="uploadify" type="file" /><br />
		<div id="attTable">
		<%
			Image_products img = new Image_products();
			ArrayList<Image_products> imgs = ((ArrayList<Image_products>) img
					.Select(Integer.parseInt(request.getParameter("id"))).ObjResult);
			for (Image_products ig : imgs) {
		%> <img style='border: 1px solid red; margin: 3px;' height='80px'
			src='../uploads/<%=ig.image_url%>' border=0 /> <%
 	}
 %>
		</div>
		</td>
		<tr>
			<td></td>
			<td><input type="submit" value="save product" /></td>
		</tr>
	</tr>
</table>
</form>
</fieldset>
</div>
<jsp:include page="../templates/Footer.jsp"></jsp:include>